<template>
  <div>
    <el-form ref="myform" :model="formItem" label-width="100px" size="mini">
      <div style="text-align: right;">
        <el-form-item>
          <el-button type="primary" @click="ok('submit')">关闭</el-button>
        </el-form-item>
      </div>
    </el-form>
  </div>
</template>

<script>
import { create } from '@neu/dcom-ui/api/changeClosing'
const formItem = {
  workNum: '',
  taskId: ''
}
export default {
  name: 'ChangeClosing',
  components: {},
  props: {
    taskId: {
      required: false,
      type: String,
      default: 'NULL'
    },
    workOrderNum: {
      required: false,
      type: String,
      default: ''
    }
  },
  data() {
    return {
      // 编辑的表单内容
      formItem: {
        ...formItem
      }
    }
  },
  watch: {},
  created() {},
  methods: {
    ok(value) {
      return new Promise(resolve => {
        this.$refs.myform.validate((valid) => {
          if (valid) {
            this.formItem.workOrderNum = this.workOrderNum
            this.formItem.taskId = this.taskId
            create(this.formItem).then(res => {
              if (res.status === 'success') {
                this.$emit('cancelNewOrderForm', 'refresh')
              }
            })
          } else {
            resolve(false)
          }
        })
      })
    },
    reset() {
      this.$refs.myform.resetFields()
      this.formItem = { ...formItem }
    }
  }
}
</script>
